<template>
    <div>
        {{shopcartList}}
        总价：{{totalPrice}}
        <h1>计算器：{{num}}</h1>
        <button @click="increment">+</button>
    </div>
</template>

<script>
//从vuex中导入createNamespacedHelpers函数
import {createNamespacedHelpers} from 'vuex'
const {mapActions:mapShopcartActions,mapState:mapShopcartState,mapGetters:mapShopcartGetters}=createNamespacedHelpers('a')
const {mapState:mapCounterState,mapMutations:mapCounterMutations}=createNamespacedHelpers('b')

export default {
    methods:{
        ...mapShopcartActions(["getShopcartList_Async"]),
        ...mapCounterMutations(["increment_Sync"]),
        getShopcartList(){
            this.getShopcartList_Async()
        },
        increment(){
            this.increment_Sync()
        }
    },
    computed:{
        ...mapShopcartState(["shopcartList"]),
        ...mapShopcartGetters(["totalPrice"]),
        ...mapCounterState(["num"])
    },
    created(){
        this.getShopcartList()
    }
}
</script>

<style>

</style>